#!/usr/bin/perl
#Author: Ian McCown
#Apache Log Project part 4

$log = $ARGV[0];
%match = ();

open FILE, "<", $log or die "log not found";
while (<FILE>) {
	$_ =~ /mod_security-message:.*\. /;
	$line = $';
	chomp $line;
	$match{$line} += 1;
}
close FILE;

$count = 0;
foreach $value ( sort { $match{$b} <=> $match{$a} } keys %match) {
	$count += 1;
	print "$count $match{$value} $value\n";
	if ( $count == 10 ) {
		last;
	}
}
